package com.xyrl.project.common.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xyrl.project.common.store.entity.StoreImage;
import com.xyrl.project.common.store.dao.StoreImageMapper;
import com.xyrl.project.common.store.enu.StoreAuthType;
import com.xyrl.project.common.store.service.StoreImageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


/**
* @className StoreImageServiceImpl.java
* @company 重庆星纭融链科技公司
* @author 徐恩源
* @version 1.0
* @date 2020-01-05 16:46:10
* @Description 店铺认证图片serviceImpl
*/
@Service
public class StoreImageServiceImpl extends ServiceImpl<StoreImageMapper, StoreImage> implements StoreImageService {

    @Override
    public List<Long> getAttIdList(long storeId, StoreAuthType storeAuthType) {
        LambdaQueryWrapper<StoreImage> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StoreImage::getStoreId, storeId);
        wrapper.eq(StoreImage::getType, storeAuthType.name());
        wrapper.select(StoreImage::getAttId);
        List<StoreImage> list = super.list(wrapper);
        List<Long> attIdList = list.stream().map(StoreImage::getAttId).collect(Collectors.toList());
        return attIdList;
    }
}
